function testf4(infile, msg, outfile)
  % TESTF4  test F4 implemention.
  % usage:
  % TESTF4(INFILE, MSG, OUTFILE) : Embed message into OUTFILE.
  % TESTF4(INFILE) : Extract message from INFILE.
  
  img = jpeg_read(infile);
  if nargin == 1
      %f4d_simple(img.coef_arrays{1});
      f4d(img.coef_arrays{1});
  else
      if nargin < 3
          outfile = [infile(1:end-3) 'f4.jpg'];
      end
      %[ret, count] = f4e_simple(img.coef_arrays{1}, msg);
      [ret, count] = f4e(img.coef_arrays{1}, msg);
      img.coef_arrays{1} = ret;
      jpeg_write(img, outfile);
  end
end
